<template>
  <div class="big">
    <nav class="top">
      <div class="div">
        <i class="el-icon-back" style="font-size: 20px;" />
        <div style="margin-left: 10px;cursor:pointer" @click="$router.push('/park')"> 返回</div>
        <div style="margin-left: 10px">|</div>
        <span style="margin-left: 10px;">添加企业</span>
      </div>
      <div>黑马管理员</div>
    </nav>
    <main class="bottom">
      <h2>企业信息</h2>
      <el-form ref="ruleForm" label-position="left" :model="ruleForm" :rules="rules">
        <el-form-item label="企业名称:" prop="name">
          <el-input v-model="ruleForm.name" placeholder="请输入企业名称" />
        </el-form-item>
        <el-form-item label="法人:" prop="legalPerson">
          <el-input v-model="ruleForm.legalPerson" placeholder="请输入法人" />
        </el-form-item>
        <el-form-item label="注册地址:" prop="registeredAddress">
          <el-input v-model="ruleForm.registeredAddress" placeholder="请输入注册地址" />
        </el-form-item>
        <el-form-item label="所在行业:" prop="industryCode">
          <el-select v-model="ruleForm.industryCode" placeholder="请选择所在行业">
            <el-option
              :key="111"
              :label="111"
              :value="111"
            />
          </el-select>
        </el-form-item>
        <el-form-item class="label" label="营业执照:" prop="businessLicenseUrl">
          <el-upload class="upload-demo" action="" multiple :file-list="fflist" :http-request="cc">
            <el-button size="small" class="button1" type="primary"><i
              class="el-icon-upload2"
            />点击上传</el-button>
            <el-button size="small" type="primary" class="button2" disabled><i
              class="el-icon-upload2"
            />已上传</el-button>
            <div slot="tip" class="el-upload__tip">
              支持扩展名：.png .jpg .jpeg，文件大小不得超过5M</div>
          </el-upload>
        </el-form-item>
        <h2 class="h2">联系人信息</h2>
        <el-form-item label="企业联系人:" prop="contact">
          <el-input />
        </el-form-item>
        <el-form-item label="联系电话:" prop="contactNumber">
          <el-input />
        </el-form-item>
      </el-form>
      <div class="div">
        <el-button @click="resetForm">重置</el-button>
        <el-button type="primary" @click="addsubmitForm">确定</el-button>
      </div>
    </main>
  </div>
</template>
<script>
import { addEnterprise, getEnTerPrise, getUpload } from '@/api/enterprise'

export default {
  data() {
    return {
      fflist: [],
      ruleForm: {
        name: '',
        legalPerson: '',
        registeredAddress: '',
        industryCode: '',
        businessLicenseUrl: '',
        businessLicenseId: '',
        contact: '',
        contactNumber: ''
      },
      rules: {
        name: [
          { required: true, message: '必填项,内容不能为空', trigger: 'blur' }
        ],
        legalPerson: [
          { required: true, message: '必填项,内容不能为空', trigger: 'blur' }
        ],
        registeredAddress: [
          { type: 'date', required: true, message: '必填项,内容不能为空', trigger: 'blur' }
        ],
        contact: [
          { type: 'date', required: true, message: '必填项,内容不能为空', trigger: 'blur' }
        ],
        businessLicenseUrl: [
          { type: 'array', required: true, message: '必填项,内容不能为空', trigger: 'blur' }
        ],
        contactNumber: [
          { required: true, message: '必填项,内容不能为空', trigger: 'blur' }
        ],
        desc: [
          { required: true, message: '请填写活动形式', trigger: 'blur' }
        ]
      }
    }
  },
  created() {
    this.getEnTerPrise()
  },
  methods: {
    async getEnTerPrise() {
      const { rows } = await getEnTerPrise()
      console.log(rows)
      this.ruleForm = rows
    },
    async addsubmitForm() {
      this.$refs.ruleForm.validate()
      const res = await addEnterprise(this.ruleForm)
      console.log(res)
    },
    resetForm() {
      this.$refs.ruleForm.resetFields()
    },
    async cc(file) {
      const datass = new FormData()
      datass.append('file', file)
      datass.append('type', '企业营业执照')
      const res = await getUpload(datass)
      console.log(res)
    }
  }
}
</script>
<style lang="scss" scoped>
.big {
    width: 100vw;
    height: 100vh;
    background-color: #f4f6f8;
    display: flex;
    flex-flow: column;

    .button1 {
        background-color: #edf5ff;
        color: #9bb3ff;
        border: none;
    }

    .button2 {
        background-color: #f1fcec;
        color: #7ccb54;
        border: none;
    }

    .top {
        height: 64px;
        background-color: #fff;
        display: flex;
        align-items: center;
        justify-content: space-between;

        .div {
            display: flex;
            align-items: center;
            margin-left: 15px;
            margin-bottom: 30px;
        }
    }

    .bottom {
        width: 1600px;
        margin: 10px auto;
        padding: 50px;
        background-color: #fff;
    }

    .el-form--label-left {
        display: flex;
        align-items: center;
        flex-wrap: wrap;

        .el-form-item {
            display: flex;
            width: 600px;
        }

        .label {
            width: 1000px;
        }

    }

    .position {
        margin-top: 50px;
    }

    .h2 {
        margin-top: 40px;
        width: 2000px;
    }

    .div {
        display: flex;
        justify-content: center;
        margin-top: 30px;
    }
}

::v-deep .el-form-item .el-input__inner {
    width: 277%;
    height: 30px;
}

::v-deep .el-input--suffix .el-input__inner {
    width: 490px;
    height: 30px;
    margin-right: 34px
}

::v-deep .el-icon-arrow-up {
    margin-right: 34px;
    margin-top: 2px;
}

::v-deep .el-select-dropdown__list {
    margin-top: 34px
}

::v-deep .el-select-dropdown {
    min-width: 525px !important;
    top: 265px !important;
    left: 1157px !important;
}

::v-deep .el-form-item__label {
    padding-right: 0px;
}</style>

